﻿layui.use(['form', 'layer'], function () {
    var form = layui.form,
        layer = parent.layer === undefined ? layui.layer : top.layer,
        $ = layui.jquery;


    function GetOrderState() {
        $.ajax({
            type: 'GET',
            url: '/InOutCash/GetYunPayOrderState/',
            data: {
                inCashId: $("#Id").val()
            },
            dataType: "json",
            success: function (res) {//res为相应体,function为回调函数
                console.log(res);
                if (res.ResultMsg) {
                    if (res.ResultCode == 200) {
                        if (res.Data) {
                            clearInterval(__GetOrderStateHandler__);
                            var alertIndex = layer.alert(res.ResultMsg, { icon: 1 }, function () {
                                layer.closeAll("iframe");
                                //刷新父页面
                                parent.location.reload();
                                top.layer.close(alertIndex);
                            });
                        } else {

                        }
                    } else {
                        layer.alert(res.ResultMsg, { icon: 5 });
                    }
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                layer.alert('操作失败！！！' + XMLHttpRequest.status + "|" + XMLHttpRequest.readyState + "|" + textStatus, { icon: 5 });
            }
        });
        return false;
    }

    var __GetOrderStateHandler__ = setInterval(GetOrderState, 3000);

});

